
package com.wallj.videolibrary.player.renderer;

import android.app.Activity;
import android.content.Context;
import android.graphics.SurfaceTexture;
import android.media.AudioManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.Surface;

import java.io.IOException;

import io.vov.vitamio.MediaPlayer;

/**
 * created by jw200 at 2019/3/22 17:47
 **/
public class VideoRenderer extends PixelRenderer {
    private final String TAG = "VideoRenderer";



    private String mFilePath;



    private Surface mDisplaySurface;

    private MediaPlayer.OnVideoSizeChangedListener mVideoSizeListener;

    public VideoRenderer(Context context) {
        super(context);
    }

    @Override
    protected void onSurfaceTextureCreated(SurfaceTexture surfaceTexture) {
        super.onSurfaceTextureCreated(surfaceTexture);
        //if (mMediaPlayer != null && !mHasPlayerDisplayed) {
        //    onInputSizeChanged(mIncommingWidth, mIncommingHeight);
        //    mDisplaySurface = new Surface(mSurfaceTexture);
        //    mMediaPlayer.setSurface(mDisplaySurface);
        //    mMediaPlayer.start();
        //    mHasPlayerDisplayed = true;
        //}
    }



    //public boolean isPlaying() {
    //    if (mMediaPlayer != null) {
    //        return mMediaPlayer.isPlaying();
    //    } else {
    //        return false;
    //    }
    //}

    //public MediaPlayer getMediaPlayer() {
    //    return mMediaPlayer;
    //}

    //public void startPlay(String filePath) {
    //    this.mFilePath = filePath;
    //    initMediaPlayer(mFilePath);
    //}
    //
    //public void resume() {
    //}
    //
    //public boolean hasPlayerDisplayed() {
    //    return mHasPlayerDisplayed;
    //}
    //
    //public boolean hasPlayerPrepared() {
    //    return mHasPlayerPrepared;
    //}

    //public void pause() {
    //    if (mMediaPlayer != null) {
    //        mDisplaySurface.release();
    //        release();
    //        mMediaPlayer.pause();
    //        mHasPlayerDisplayed = false;
    //    }
    //}

    //public void stopPlay() {
    //    if (mMediaPlayer != null) {
    //        synchronized (mLock) {
    //            release();
    //        }
    //        mMediaPlayer.release();
    //        mHasPlayerPrepared = false;
    //        mMediaPlayer = null;
    //    }
    //}

    //public void seekTo(long time) {
    //    if (mMediaPlayer != null) {
    //        mMediaPlayer.seekTo(time);
    //    }
    //}



    public void setOnVideoSizeChangedListener(MediaPlayer.OnVideoSizeChangedListener listener) {
        this.mVideoSizeListener = listener;
    }

}
